package world.ztomorrow.author.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import world.ztomorrow.author.dto.req.BookAddReqDto;
import world.ztomorrow.author.dto.req.ChapterAddReqDto;
import world.ztomorrow.author.dto.req.ChapterUpdateReqDto;
import world.ztomorrow.author.dto.resp.BookChapterRespDto;
import world.ztomorrow.author.dto.resp.BookInfoRespDto;
import world.ztomorrow.author.dto.resp.ChapterContentRespDto;
import world.ztomorrow.common.dto.PageReqDto;
import world.ztomorrow.common.dto.PageRespDto;
import world.ztomorrow.common.dto.RestResp;

@FeignClient("yc-novel")
@Component
public interface NovelClient {

    /**
     * 小说发布接口
     */
    @PostMapping("/get_author/book")
    RestResp<Void> publishBook(@RequestBody BookAddReqDto dto);

    /**
     * 小说发布列表查询接口
     */
    @PostMapping("/get_author/books")
    RestResp<PageRespDto<BookInfoRespDto>> listBooks(@RequestBody PageReqDto dto);

    /**
     * 小说章节发布接口
     */
    @PostMapping("/book/chapter")
    RestResp<Void> publishBookChapter(
            @RequestBody ChapterAddReqDto dto) ;

    /**
     * 小说章节删除接口
     */
    @DeleteMapping("/book/chapter/{chapterId}")
    RestResp<Void> deleteBookChapter(@PathVariable("chapterId") Long chapterId);

    /**
     * 小说章节查询接口
     */
    @GetMapping("/book/chapter/{chapterId}")
    RestResp<ChapterContentRespDto> getBookChapter(@PathVariable("chapterId") Long chapterId);

    /**
     * 小说章节更新接口
     */
    @PutMapping("/book/chapter/{chapterId}")
    RestResp<Void> updateBookChapter(
            @PathVariable("chapterId") Long chapterId,
            @RequestBody ChapterUpdateReqDto dto);

    /**
     * 小说章节发布列表查询接口
     */
    @PostMapping("/book/chapters/{bookId}")
    RestResp<PageRespDto<BookChapterRespDto>> listBookChapters(
            @PathVariable("bookId") Long bookId,
            @RequestBody PageReqDto dto);
}
